package game.birds
{
	import game.Settings;
	import game.Utils;
	import windowsfla.*;
	/**
	 * ...
	 * @author Goretskiy Alex
	 */
	public class BirdFly extends Bird
	{
		//--------------------------------------------------------------------------
		//
		//  Variables
		//
		//--------------------------------------------------------------------------
		
		//----------------------------------
		//  Protected variables
		//----------------------------------
		
		
		
		//--------------------------------------------------------------------------
		//
		//  Getters and setters
		//
		//--------------------------------------------------------------------------
		
		
		//--------------------------------------------------------------------------
		//
		//  Methods
		//
		//--------------------------------------------------------------------------
		
		//----------------------------------
		//  Constructor
		//----------------------------------
		
		public function BirdFly() 
		{
			super();
		}
		
		//----------------------------------
		//  Public methods
		//----------------------------------
		
		/**
		 * 
		 * @param	e
		 */
		override public function init( bird_type:int ):void 
		{
			super.init( bird_type );
			
			_direction = Utils.randNumber( 0, 1 );
			if ( _direction == 0 )
			{
				_direction = -1;
			}
			
			if ( _direction == -1 )
			{
				x = Settings.WORLD_WIDTH + width;
				Utils.PlayDeep( this, "bird_" + String( type ) + "_right" );
				//rotationY = 180;
			}
			else
			{
				x = - width;
				Utils.PlayDeep( this, "bird_" + String( type ) + "_left" );
			}
			
			y = Utils.randNumber( 0, Settings.WORLD_HEIGHT / Settings.WORLD_CELL_SIZE - 1 );
			y *= Settings.WORLD_CELL_SIZE;
		}
		
		/**
		 * 
		 */
		override public function update():void
		{
			super.update();
			
			x += Settings.BIRD_SPEED * _direction;
			if ( x <= - width * 2 || x >= Settings.WORLD_WIDTH + width * 2 )
			{
				destroy();
			}
		}
		
	}

}